<?php 
    include 'admin/class/database.php';
    $pdo = Database::connect();
	
    $id = null;
    if ( !empty($_GET['id'])) {
        $id = $_REQUEST['id'];
    }     
    if ( null==$id ) {
        header("Location: posts");
    }     

    //Exibe sem Loop
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    //Seleciona a tabela
    $sql = "SELECT * FROM posts where id = ?";
    $q = $pdo->prepare($sql);
    $q->execute(array($id));
    $data = $q->fetch(PDO::FETCH_ASSOC);
    //Variáveis que serão exibidas
	$titulo_post = $data['titulo_post'];		
	$data_post = $data['data_post'];
	$corpo_post = $data['corpo_post'];	
	$foto = $data['foto'];
    Database::disconnect();
    //exibe sem Loop
	
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script type="text/javascript">id=10</script>
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
<?php include 'header.php'; ?>
		<div class="content">
			<div class="conteudo conteudo-cafe-journal">
				<div class="wrapper-blog">
                        <div style="float:left">
                        	<h2>ACONTECE NO CAFÉ JOURNAL </h2>
                        </div>
                    <div style="float:right">
                        <a href="javascript:history.back();" class="link-post">
                        	<h2><i class="fa fa-chevron-circle-left"></i> Voltar</h2>
                        </a>
                    </div>
                    <div class="post">
                        <div class="head-post">
                            <h2><?php echo $titulo_post; ?> </h2>
                            <p><?php echo $data_post; ?></p>
                        </div>
                        <div class="body-post">
                        	<center><?php echo "<img style='height:300px' src='admin/img/uploads/".$foto."' />"?></center>
                            <p><?php echo $corpo_post; ?></p>                   
                        </div>
                        <hr />                        
                    </div><!--/.posts-->                    
				</div><!--/wrapper-content-cafe-journal-->
                
				<div class="sidebar-blog">
                	<div class="sidebar-blog-box">
                    	<h2>ARQUIVO DO BLOG</h2>
                        <?php $sql = 'SELECT * FROM posts ORDER BY data_post DESC LIMIT 5';  foreach ($pdo->query($sql) as $row): ?>
                        <a href="post.php?id=<?php echo $row['id']?>" class="link-post">
                        	<p><?php echo $row['titulo_post']; ?></p>
                        </a>
                        <?php endforeach; ?>
                    </div>

                	<div class="sidebar-blog-box">
                    	<iframe src="//www.facebook.com/plugins/likebox.php?href=https://www.facebook.com/pages/Caf%C3%A9-Journal-Brasil-Oficial/204618459581973?fref=ts&amp;width=192&amp;height=358&amp;show_faces=true&amp;colorscheme=light&amp;stream=false&amp;show_border=true&amp;header=false&amp;appId=149155915258970" scrolling="no" frameborder="0" style="border:none; overflow:hidden; background-color:#FFF; width:78%; height:300px;" allowTransparency="false"></iframe>
                    </div>                    
                    	


				</div><!--/wrapper-img-cafe-journal-->
				<span class="clear"></span>
			</div><!--/conteudo-home-->
			<span class="clear"></span>
		</div><!--/content-->
		<span class="clear"></span>
	</div><!--/wrap-->
<?php include 'footer.php'; ?>